package com.bw.base.mvvm

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModelProvider

abstract class BaseActivity<VDB :ViewDataBinding,VM:BaseViewModel>:AppCompatActivity() {
    lateinit var binding :VDB
    lateinit var viewModel:VM
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this,getLayoutId())
        viewModel = ViewModelProvider(this).get(getViewModel())
        initView()
        initData()

    }

    abstract fun initView()

    abstract fun initData()

    abstract fun getViewModel(): Class<VM>

    abstract fun getLayoutId(): Int
}